using UnityEngine;
using UnityEngine.UI;
using QFramework;
using UnityEngine.SceneManagement;

namespace survivor
{
	public class UIGameOverPanelData : UIPanelData
	{
	}
	public partial class UIGameOverPanel : UIPanel
	{
		protected override void OnInit(IUIData uiData = null)
		{
			mData = uiData as UIGameOverPanelData ?? new UIGameOverPanelData();
			// please add init code here
			ActionKit.OnUpdate.Register(()=>{
				if(Input.GetKeyDown(KeyCode.Space)){
					Global.Cleanup();
					this.CloseSelf();
					SceneManager.LoadScene("game");
				}
			}).UnRegisterWhenGameObjectDestroyed(gameObject);

			BtnBackToStart.onClick.AddListener(()=>{
				Global.Cleanup();
				this.CloseSelf();
				SceneManager.LoadScene("GameStart");
			});
		}
		
		protected override void OnOpen(IUIData uiData = null)
		{
		}
		
		protected override void OnShow()
		{
		}
		
		protected override void OnHide()
		{
		}
		
		protected override void OnClose()
		{
			// 确保所有事件监听器都被清理
			BtnBackToStart.onClick.RemoveAllListeners();
		}
	}
}
